<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0px;
            padding: 0px;
        }
        .banner {
            width: 1200px;
            margin: 100px auto 0px;
            position: relative;
        }
        .box {
            width: 1200px;
            height: 500px;
        }
        .box1 {
            background-color: lightgreen;
            background: url(../jsday13/images/1.jpg) no-repeat center 10px / 1200px 500px;
            display: block;
        }
        .box2 {
            background-color: rgb(164, 167, 39);
            background: url(../jsday13/images/2.jpg) no-repeat center 10px / 1200px 500px;
            display: none;
        }
        .box3 {
            background-color: rgb(235, 103, 26);
            background: url(../jsday13/images/3.jpg) no-repeat center 10px / 1200px 500px;
            display: none;
        }
        button {
            width: 15px;
            height: 15px;
            border:none;
            box-sizing: border-box;
            border-radius: 50%;
            margin: 15px;
        }
        .btn {
            position: absolute;
            left: 50%;
            transform: translateX(-50%);
            bottom: 0px;
        }
    </style>
</head>
<body>
    <div class="banner">
        <div class="box1 box"></div>
        <div class="box2 box"></div>
        <div class="box3 box"></div>
        <section class="btn">
            <button></button>
            <button></button>
            <button></button>
        </section>
    </div>
    
    <script>
        var btnEle = document.querySelectorAll("button");
        var divEle = document.querySelectorAll(".box");
        var newArr = Array.from(divEle) ; 
        Array.from(btnEle).forEach(function(item,key,arr){
            item.onmouseover = function (){
                arr.forEach(function(ite,k){
                    if ( k == key ){
                        ite.style.backgroundColor = '#666'
                    } else {
                        ite.style.backgroundColor = '#fff'
                    }
                })
                for ( let i = 0 ; i < newArr.length ; i ++ ){
                    newArr[i].style.display = 'none';
                }
                newArr[key].style.display = 'block';
            }
        });
    </script>
</body>
</html>